package router

import (
	global "yundata-service/internal"
	dpt "yundata-service/pkg/api/ucenter"

	"github.com/gin-gonic/gin"
)

func InitDptRouter(e *gin.Engine) {
	// token验证
	e.Use(CheckToken())

	dptAction := dpt.DptAction{}
	dptAction.ActionModel = global.ActionModel{}
	e.Use(ActionMiddleware(&dptAction.ActionModel))

	// 用户相关
	userRouterGroup := e.Group("/api/v1/dept", func(ctx *gin.Context) {})
	{
		// 部门树
		userRouterGroup.POST("/tree", func(ctx *gin.Context) {
			dptAction.GetDptTree()
		})

		// 新增用户
		userRouterGroup.POST("/add", func(ctx *gin.Context) {
			dptAction.AddDpt()
		})

		// 更新用户
		userRouterGroup.POST("/update", func(ctx *gin.Context) {
			dptAction.UpdateDpt()
		})

		// 删除用户
		userRouterGroup.POST("/delete", func(ctx *gin.Context) {
			dptAction.DeleteDpt()
		})
	}
}
